Skip to contents

Gambling neighbourhoods using DBSCAN and eps=500m

Load data

Load the geographical data (spatial points dataframe) containing the coordinates of gambling premises.

library(devtools)
load_all()
xy <- readRDS("data/xy.rds")

MinPts=2 with eps=500m

Load dataframe with coordinates and cluster assignments

res2_dbscan_eps500 <- readRDS("results/dbscan_results_eps0.45_MinPts2.rds")
# Create a data frame from the spatial points
df2_dbscan_eps500 <- create_df(res2_dbscan_eps500,xy)
head(df2_dbscan_eps500)
#> # A tibble: 6 × 5
#>    LONG   LAT cluster    ID   Pop
#>   <dbl> <dbl> <fct>   <int> <dbl>
#> 1 -2.10  57.1 0        7246     0
#> 2 -2.10  57.1 1        7929     2
#> 3 -2.10  57.1 1        4660     2
#> 4 -2.11  57.1 2        6787     2
#> 5 -2.11  57.1 2        5866     2
#> 6 -2.11  57.1 0        4658     0
dim(df2_dbscan_eps500)
#> [1] 8761    5

Number of clusters (excluding noise):

#> [1] 1037

Number of noise points:

#> [1] 6296

Leaflet map for MinPts=2, eps=500m

MinPts=3 with eps=500m

Load dataframe with coordinates and cluster assignments

#> # A tibble: 6 × 5
#>    LONG   LAT cluster    ID   Pop
#>   <dbl> <dbl> <fct>   <int> <dbl>
#> 1 -2.10  57.1 0        7246     0
#> 2 -2.10  57.1 0        7929     0
#> 3 -2.10  57.1 0        4660     0
#> 4 -2.11  57.1 0        6787     0
#> 5 -2.11  57.1 0        5866     0
#> 6 -2.11  57.1 0        4658     0
#> [1] 8761    5

Number of clusters (excluding noise):

#> [1] 233

Number of noise points:

#> [1] 7904

Leaflet map for MinPts=3, eps=500m

MinPts=4 with eps=500m

Load dataframe with coordinates and cluster assignments

#> # A tibble: 6 × 5
#>    LONG   LAT cluster    ID   Pop
#>   <dbl> <dbl> <fct>   <int> <dbl>
#> 1 -2.10  57.1 0        7246     0
#> 2 -2.10  57.1 0        7929     0
#> 3 -2.10  57.1 0        4660     0
#> 4 -2.11  57.1 0        6787     0
#> 5 -2.11  57.1 0        5866     0
#> 6 -2.11  57.1 0        4658     0
#> [1] 8761    5

Number of clusters (excluding noise):

#> [1] 85

Number of noise points:

#> [1] 8348

Leaflet map for MinPts=4, eps=500m

MinPts=5 with eps=500m

Load dataframe with coordinates and cluster assignments

#> # A tibble: 6 × 5
#>    LONG   LAT cluster    ID   Pop
#>   <dbl> <dbl> <fct>   <int> <dbl>
#> 1 -2.10  57.1 0        7246     0
#> 2 -2.10  57.1 0        7929     0
#> 3 -2.10  57.1 0        4660     0
#> 4 -2.11  57.1 0        6787     0
#> 5 -2.11  57.1 0        5866     0
#> 6 -2.11  57.1 0        4658     0
#> [1] 8761    5

Number of clusters (excluding noise):

#> [1] 32

Number of noise points:

#> [1] 8560

Leaflet map for MinPts=5, eps=500m

MinPts=10 with eps=500m

Load dataframe with coordinates and cluster assignments

#> # A tibble: 6 × 5
#>    LONG   LAT cluster    ID   Pop
#>   <dbl> <dbl> <fct>   <int> <dbl>
#> 1 -2.10  57.1 0        7246     0
#> 2 -2.10  57.1 0        7929     0
#> 3 -2.10  57.1 0        4660     0
#> 4 -2.11  57.1 0        6787     0
#> 5 -2.11  57.1 0        5866     0
#> 6 -2.11  57.1 0        4658     0
#> [1] 8761    5

Number of clusters (excluding noise):

#> [1] 5

Number of noise points:

#> [1] 8711

Leaflet map for MinPts=10, eps=500m

MinPts=15 with eps=500m

Load dataframe with coordinates and cluster assignments

#> # A tibble: 6 × 5
#>    LONG   LAT cluster    ID   Pop
#>   <dbl> <dbl> <fct>   <int> <dbl>
#> 1 -2.10  57.1 0        7246     0
#> 2 -2.10  57.1 0        7929     0
#> 3 -2.10  57.1 0        4660     0
#> 4 -2.11  57.1 0        6787     0
#> 5 -2.11  57.1 0        5866     0
#> 6 -2.11  57.1 0        4658     0
#> [1] 8761    5

Number of clusters (excluding noise):

#> [1] 0

Number of noise points:

#> [1] 8761

No Leaflet map for MinPts=15, eps=500m

MinPts=20 with eps=500m

Load dataframe with coordinates and cluster assignments

#> # A tibble: 6 × 5
#>    LONG   LAT cluster    ID   Pop
#>   <dbl> <dbl> <fct>   <int> <dbl>
#> 1 -2.10  57.1 0        7246     0
#> 2 -2.10  57.1 0        7929     0
#> 3 -2.10  57.1 0        4660     0
#> 4 -2.11  57.1 0        6787     0
#> 5 -2.11  57.1 0        5866     0
#> 6 -2.11  57.1 0        4658     0
#> [1] 8761    5

Number of clusters (excluding noise):

#> [1] 0

Number of noise points:

#> [1] 8761

No Leaflet map for MinPts=20, eps=500m